<!-- 考试-->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="卷名" prop="courseName">
        <el-input
          v-model="queryParams.courseName"
          placeholder="请输入课件名"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="searchTable()"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="emptySearch()"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-col :span="24">
      <el-table :data="tableData" border v-loading="loading">
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="examinationPlanName" label="卷名" align="center">
        </el-table-column>
        <el-table-column prop="examinationTime" label="考试日期" align="center">
        </el-table-column>
        <el-table-column prop="teacherName" label="老师名" align="center">
        </el-table-column>
        <el-table-column prop="passScore" label="及格分数" align="center">
        </el-table-column>
        <el-table-column prop="totalScore" label="总分数" align="center">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200" align="center">
          <template slot-scope="scope">
            <el-button @click="getTrainInfo(scope.row)" type="text" size="small"
              >查看</el-button
            >
            <el-button @click="goToPaper(scope.row)" type="text" size="small"
              >去考试</el-button
            >
            <!-- <el-button @click="practiceTest(scope.row)" type="text" size="small"
              >模拟考试</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>
    </el-col>
    <el-row>
      <el-col>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <ExaminationInfo ref="ExaminationInfoRef"></ExaminationInfo>
    <SimulateExamin ref="SimulateExaminRef"></SimulateExamin>
    <FormalExamin ref="FormalExaminRef"></FormalExamin>
    <StudyCourse ref="StudyCourseRef" @playerEnd="playerEnd"></StudyCourse>
    <PaperResult ref="PaperResultRef"  @refreshList="getList" ></PaperResult>
  </div>
</template>

<script>
import {
  getExaminationPlanList,
  delExaminationPlan,
} from "@/api/train/index.js";

import ExaminationInfo from "./component/ExaminationInfo.vue";
import SimulateExamin from "./component/SimulateExamin.vue";
import StudyCourse from "./component/StudyCourse.vue";
import PaperResult from "./component/PaperResult.vue";
import FormalExamin from "./component/FormalExamin.vue";
export default {
  components: {
    ExaminationInfo,
    SimulateExamin,
    StudyCourse,
    PaperResult,
    FormalExamin,
  },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      tableData: [],
      total: 1,
      selRow: {},
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        courseName: undefined,
        professionId: undefined,
        courseType: 0,
        orderByColumn: "a.create_time",
        isAsc: "desc",
      },
    };
  },
  computed: {},
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    // 点击页码及上一页下一页按钮操作
    currentChange(val) {
      this.queryParams.pageNum = val;
      //刷新表格
      this.getList();
    },
    //每页展示几条按钮操作
    sizeChange(val) {
      this.queryParams.pageSize = val;
      //刷新表格
      this.getList();
    },
    //获取试卷列表
    getList() {
      this.loading = true;
      getExaminationPlanList(this.queryParams).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.tableData = res.rows;
          this.total = res.total;
          this.loading = false;
        }
      });
    },
    //搜索
    searchTable() {
      this.getList();
    },
    //重置搜索框
    emptySearch() {
      queryParams.courseName = "";
    },
    //试卷详情
    getTrainInfo(row) {
      this.$refs.ExaminationInfoRef.show(row);
    },
    //去考试
    goToPaper(row) {
      this.selRow = row;
      this.$refs.StudyCourseRef.show(row);
    },

    //模拟考试
    practiceTest(row) {
      this.selRow = row;
      this.$refs.SimulateExaminRef.show(this.selRow);
    },

    //视频播放完毕回调
    playerEnd() {
      console.log("走了吗")
      this.getList();
      this.$refs.FormalExaminRef.show(this.selRow);
    },
  },
};
</script>
>

<style lang="scss" scoped>
@import "./css/index.scss";
</style>>
